import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';

import { AppModule } from './app.module';

import * as compression from 'compression';
import { Logger } from './middlewares/logger/logger';

async function bootstrap() {
  const appOptions = { cors: true, looger: new Logger() };
  const app = await NestFactory.create(AppModule, appOptions);
  app.setGlobalPrefix('api');
  app.use(compression());

  const options = new DocumentBuilder()
                  .setTitle('Nest Spring Blog')
                  .setDescription('The Blog API description')
                  .setVersion('1.0.0')
                  .setBasePath('api')
                  .build();
  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('/docs', app, document);

  await app.listen(3000);
}
bootstrap();
